/**
 * @mbggenerated
 * @author wujian
 */
package bearworker.zxl.dao.mapper;

import bearworker.zxl.entity.DeliveryOrderDetails;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface DeliveryOrderDetailsMapper {
    /* @mbggenerated */
    @Delete({
        "delete from delivery_order_details",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /* @mbggenerated */
    @Insert({
        "insert into delivery_order_details (order_id, pre_ord_id, ",
        "recipients_id, package_kilo, ",
        "original_price, courier_number, ",
        "create_time)",
        "values (#{orderId,jdbcType=INTEGER}, #{preOrdId,jdbcType=INTEGER}, ",
        "#{recipientsId,jdbcType=INTEGER}, #{packageKilo,jdbcType=DOUBLE}, ",
        "#{originalPrice,jdbcType=DOUBLE}, #{courierNumber,jdbcType=VARCHAR}, ",
        "#{createTime,jdbcType=TIMESTAMP})"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insert(DeliveryOrderDetails record);

    /* @mbggenerated */
    @InsertProvider(type=DeliveryOrderDetailsSqlProvider.class, method="insertSelective")
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insertSelective(DeliveryOrderDetails record);

    /* @mbggenerated */
    @Select({
        "select",
        "id, order_id, pre_ord_id, recipients_id, package_kilo, original_price, courier_number, ",
        "create_time",
        "from delivery_order_details",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="order_id", property="orderId", jdbcType=JdbcType.INTEGER),
        @Result(column="pre_ord_id", property="preOrdId", jdbcType=JdbcType.INTEGER),
        @Result(column="recipients_id", property="recipientsId", jdbcType=JdbcType.INTEGER),
        @Result(column="package_kilo", property="packageKilo", jdbcType=JdbcType.DOUBLE),
        @Result(column="original_price", property="originalPrice", jdbcType=JdbcType.DOUBLE),
        @Result(column="courier_number", property="courierNumber", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    DeliveryOrderDetails selectByPrimaryKey(Integer id);

    /* @mbggenerated */
    @UpdateProvider(type=DeliveryOrderDetailsSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(DeliveryOrderDetails record);

    /* @mbggenerated */
    @Update({
        "update delivery_order_details",
        "set order_id = #{orderId,jdbcType=INTEGER},",
          "pre_ord_id = #{preOrdId,jdbcType=INTEGER},",
          "recipients_id = #{recipientsId,jdbcType=INTEGER},",
          "package_kilo = #{packageKilo,jdbcType=DOUBLE},",
          "original_price = #{originalPrice,jdbcType=DOUBLE},",
          "courier_number = #{courierNumber,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(DeliveryOrderDetails record);
    
    @Select({
        "select",
        "id, order_id, pre_ord_id, recipients_id, package_kilo, original_price, courier_number, ",
        "create_time",
        "from delivery_order_details",
        "where order_id = #{orderId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="order_id", property="orderId", jdbcType=JdbcType.INTEGER),
        @Result(column="pre_ord_id", property="preOrdId", jdbcType=JdbcType.INTEGER),
        @Result(column="recipients_id", property="recipientsId", jdbcType=JdbcType.INTEGER),
        @Result(column="package_kilo", property="packageKilo", jdbcType=JdbcType.DOUBLE),
        @Result(column="original_price", property="originalPrice", jdbcType=JdbcType.DOUBLE),
        @Result(column="courier_number", property="courierNumber", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    DeliveryOrderDetails selectByOrderId(Integer orderId);
    
    @Select({
    	"<script>" +
        "select",
        "id, order_id, pre_ord_id, recipients_id, package_kilo, original_price, courier_number, ",
        "create_time",
        "from delivery_order_details",
        "where order_id in"
		+ "<foreach item='item' index='index' collection='orderIdList' open='(' separator=',' close=')'>"
			+ "#{item}"
		+ "</foreach>"
        + "</script>"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="order_id", property="orderId", jdbcType=JdbcType.INTEGER),
        @Result(column="pre_ord_id", property="preOrdId", jdbcType=JdbcType.INTEGER),
        @Result(column="recipients_id", property="recipientsId", jdbcType=JdbcType.INTEGER),
        @Result(column="package_kilo", property="packageKilo", jdbcType=JdbcType.DOUBLE),
        @Result(column="original_price", property="originalPrice", jdbcType=JdbcType.DOUBLE),
        @Result(column="courier_number", property="courierNumber", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<DeliveryOrderDetails> selectByOrderIdList(@Param("orderIdList")List<Integer> orderIdList);
}